#!/bin/bash

# 安装busybox, 需要里面的devmem工具
#sudo apt install busybox

# pinmux.0x0c303000 and pinmux.0x0c303008 are for CAN1
# pinmux.0x0c303010 and pinmux.0x0c303018 are for CAN0
# 检查当前的寄存器值
#sudo busybox devmem 0x0c303000	# 0x0000C055
#sudo busybox devmem 0x0c303008	# 0x0000C055
#sudo busybox devmem 0x0c303010	# 0x0000C059
#sudo busybox devmem 0x0c303018	# 0x0000C059

# 用devmem修改寄存器
#sudo busybox devmem 0x0c303000 32 0x0000C400
#sudo busybox devmem 0x0c303008 32 0x0000C458
#sudo busybox devmem 0x0c303010 32 0x0000C400
#sudo busybox devmem 0x0c303018 32 0x0000C458

# 改完后检查
#sudo busybox devmem 0x0c303000	# 0x0000C400
#sudo busybox devmem 0x0c303008	# 0x0000C458
#sudo busybox devmem 0x0c303010	# 0x0000C400
#sudo busybox devmem 0x0c303018	# 0x0000C458

#sudo modprobe can
#sudo modprobe can_raw
#sudo modprobe mttcan



#!/bin/sh

sudo busybox devmem 0x0c303000 32 0x0000C400
sudo busybox devmem 0x0c303008 32 0x0000C458
sudo busybox devmem 0x0c303010 32 0x0000C400
sudo busybox devmem 0x0c303018 32 0x0000C458

sudo modprobe can
sudo modprobe can_raw
sudo modprobe mttcan

sudo sh -c 'echo 0x600 > /sys/devices/platform/c310000.mttcan/net/can0/tdc_offset'
sudo sh -c 'echo 0x600 > /sys/devices/platform/c320000.mttcan/net/can1/tdc_offset'

sudo ip link set down can0
sudo ip link set can0 type can bitrate 500000 sample-point 0.8 dbitrate 2000000 dsample-point 0.8 berr-reporting on fd on restart-ms 100
sudo ip link set up can0 mtu 72
sudo ifconfig can0 txqueuelen 1000
# ip -s -d link show can0

sudo ip link set down can1
sudo ip link set can1 type can bitrate 500000 sample-point 0.8 dbitrate 2000000 dsample-point 0.8 berr-reporting on fd on restart-ms 100
sudo ip link set up can1 mtu 72
sudo ifconfig can1 txqueuelen 1000
# ip -s -d link show can1

sudo ip link set dev can0 up
sudo ip link set dev can1 up


